<?php

mysql_connect("designinfo.se.mysql", "designinfo_se", "KvHhwnt8") or die(mysql_error());
mysql_select_db("designinfo_se") or die(mysql_error());

//mysql_connect("localhost", "root", "linali") or die(mysql_error());
//mysql_select_db("cms_linali") or die(mysql_error());

/*
mysql_query("DROP TABLE IF EXISTS main_heading");
$response=mysql_query("CREATE TABLE main_heading 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              text_en VARCHAR(1000),
              text_sv VARCHAR(1000)
            )");

//$response=mysql_query("insert into notifications(type,text_en) values(0,'commented at item')");
//$response=mysql_query("insert into notifications(type,text_en) values(1,'added your shop as favorite')");

mysql_query("DROP TABLE IF EXISTS sub_heading");
$response=mysql_query("CREATE TABLE sub_heading 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              text_en VARCHAR(5000),
              text_sv VARCHAR(5000)
            )");

mysql_query("DROP TABLE IF EXISTS description");
$response=mysql_query("CREATE TABLE description 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              text_en VARCHAR(5000),
              text_sv VARCHAR(5000)
            )");


mysql_query("DROP TABLE IF EXISTS image");
$response=mysql_query("CREATE TABLE image 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              name VARCHAR(500),
              path VARCHAR(500)
            )");


mysql_query("DROP TABLE IF EXISTS url_link");
$response=mysql_query("CREATE TABLE url_link 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              link_en VARCHAR(500),
              link_sv VARCHAR(500)
            )");


mysql_query("DROP TABLE IF EXISTS admin");
$response=mysql_query("CREATE TABLE admin 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              username VARCHAR(50),
              password VARCHAR(50)
            )");



mysql_query("DROP TABLE IF EXISTS PA1");
$response=mysql_query("CREATE TABLE PA1 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");


mysql_query("DROP TABLE IF EXISTS main_menu");
$response= mysql_query("create table main_menu
            ( id BIGINT PRIMARY KEY NOT NULL,
              MH BIGINT,
              link1 BIGINT,
              link2 BIGINT,
              FOREIGN KEY (MH) REFERENCES main_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (link1) REFERENCES url_link (id) ON DELETE CASCADE,
              FOREIGN KEY (link2) REFERENCES url_link (id) ON DELETE CASCADE
)");

mysql_query("DROP TABLE IF EXISTS common_footer");
$response= mysql_query("create table common_footer
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,
              text1_en varchar(500),
              text2_en varchar(500),
              text3_en varchar(500),
              text4_en varchar(500),
              text1_sv varchar(500),
              text2_sv varchar(500),
              text3_sv varchar(500),
              text4_sv varchar(500)
)");


mysql_query("DROP TABLE IF EXISTS PA2");
$response=mysql_query("CREATE TABLE PA2 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");


mysql_query("DROP TABLE IF EXISTS PA3");
$response=mysql_query("CREATE TABLE PA3 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");




mysql_query("DROP TABLE IF EXISTS PA4");
$response=mysql_query("CREATE TABLE PA4 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");

mysql_query("DROP TABLE IF EXISTS PA5");
$response=mysql_query("CREATE TABLE PA5 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");

mysql_query("DROP TABLE IF EXISTS PA6");
$response=mysql_query("CREATE TABLE PA6 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");

mysql_query("DROP TABLE IF EXISTS PA7");
$response=mysql_query("CREATE TABLE PA7 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");

mysql_query("DROP TABLE IF EXISTS PA8");
$response=mysql_query("CREATE TABLE PA8 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
            )");



mysql_query("DROP TABLE IF EXISTS PA9");
$response=mysql_query("CREATE TABLE PA9 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              LINK BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE,
              FOREIGN KEY (LINK) REFERENCES url_link (id) ON DELETE CASCADE
            )");


mysql_query("DROP TABLE IF EXISTS PA11");
$response=mysql_query("CREATE TABLE PA11 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
           
            )");



mysql_query("DROP TABLE IF EXISTS PA10");
$response=mysql_query("CREATE TABLE PA10 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              que BIGINT,
              ans BIGINT,
              imgQ BIGINT,
              imgA BIGINT,
              FOREIGN KEY (que) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (ans) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (imgQ) REFERENCES image (id) ON DELETE CASCADE,
              FOREIGN KEY (imgA) REFERENCES image (id) ON DELETE CASCADE
            )");

*/

mysql_query("DROP TABLE IF EXISTS PA12");
$response=mysql_query("CREATE TABLE PA12 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              seg BIGINT, 
              SH BIGINT,
              DES BIGINT,
              IMAGE BIGINT,
              FOREIGN KEY (SH) REFERENCES sub_heading (id) ON DELETE CASCADE,
              FOREIGN KEY (DES) REFERENCES description (id) ON DELETE CASCADE,
              FOREIGN KEY (IMAGE) REFERENCES image (id) ON DELETE CASCADE
           
            )");

mysql_query("DROP TABLE IF EXISTS CONTACT");
$response=mysql_query("CREATE TABLE CONTACT 
            ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, 
              HEADING_EN VARCHAR(1000),
              NAME_EN VARCHAR(1000),
              EMAIL_EN VARCHAR(1000),
              TEXT_EN VARCHAR(1000),
              BUTTON_EN VARCHAR(1000),
              HEADING_SV VARCHAR(1000),
              NAME_SV VARCHAR(1000),
              EMAIL_SV VARCHAR(1000),
              TEXT_SV VARCHAR(1000),
              BUTTON_SV VARCHAR(1000)
              
            )");

var_dump("\n"+$response+"\n");

?>
